package Exam.Ticket_one;

import java.util.Scanner;



public class ticket_with_method {
        /*机票价格按照淡季旺季、头等舱和经济舱收费、输入机票原价、月份和头等舱或经济舱。
        按照如下规则计算机票价格:
        旺季(5-10月)头等舱9折，经济舱8.5折，淡季(11月到来年4月)头等舱7折，经济舱6.5折。*/

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        System.out.println("请输入机票原价：");
        int ticket = sc.nextInt();
        System.out.println("请输入当前月份：");
        int month = sc.nextInt();
        System.out.println("请输入当前购买舱位：1 为头等舱, 0 为经济舱");
        int type = sc.nextInt();

        //判断
        if (month >= 5 && month <= 10) {
            //旺季
            ticket = getPrice(ticket,type,0.9,0.85);
        } else if (month >= 1 && month <= 4 || month >= 11 && month <= 12) {
            //淡季
            ticket = getPrice(ticket,type,0.7,0.65);
        } else {
            //非法数据
            System.out.println("请输入正确数据！！");
        }
        System.out.println("价格为：" + ticket);
    }

    public static int getPrice(int ticket, int type, double v1, double v0) {
        if (type == 1) {
            //经济
            ticket = (int) (ticket * v0);
        } else if (type == 0) {
            //头等
            ticket = (int) (ticket * v1);
        }
        return ticket;
    }

    //可以用ctrl + alt + M 快速抽取方法
}
